Skip to content

fix: isolate env variables between cli server command runs#1366

Merged
cristipufu merged 1 commit intomainfrom
fix/cli-server-env-isolation
Feb 24, 2026
Merged

fix: isolate env variables between cli server command runs#1366
cristipufu merged 1 commit intomainfrom
fix/cli-server-env-isolation

Conversation

@cristipufu
Copy link
Member

Summary

  • Fix env variable leakage between sequential cli server command runs by resetting to a server baseline env captured at startup instead of merging request env vars on top of current process state
  • Add asyncio.Lock to serialize command execution and prevent concurrent os.environ mutation
  • Bump version to 2.9.3

Test plan

  • Run two sequential commands via the server with different environmentVariables payloads and verify the second run does not see env vars from the first
  • Verify server baseline env vars (PATH, HOME, etc.) remain available during command execution
  • Verify concurrent requests are properly serialized

🤖 Generated with Claude Code

@github-actions github-actions bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository labels Feb 24, 2026
@cristipufu cristipufu requested a review from Copilot February 24, 2026 12:03

This comment was marked as outdated.

This comment was marked as outdated.

@cristipufu cristipufu force-pushed the fix/cli-server-env-isolation branch 2 times, most recently from b72b0cf to a3f5477 Compare February 24, 2026 13:15
- Replace global lock/baseline_env with _ServerState container
- Clear and restore os.environ from server baseline between requests
- Add early validation for environmentVariables type
- Handle os.chdir errors inside the lock to avoid TOCTOU races
- Protect finally-block chdir to ensure env is always restored
- Add env isolation tests for sequential server requests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@cristipufu cristipufu force-pushed the fix/cli-server-env-isolation branch from a3f5477 to 7170dda Compare February 24, 2026 13:36
@cristipufu cristipufu merged commit 03e0aa2 into main Feb 24, 2026
95 checks passed
@cristipufu cristipufu deleted the fix/cli-server-env-isolation branch February 24, 2026 13:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-llamaindex Triggers tests in the uipath-llamaindex-python repository

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants